home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / pleas / ole / excel / xl_simpl.txt < prev   
Encoding:
Text File  |  1994-06-10  |  623 b   |  26 lines

  1. ' 1. stuffs a label and some values in cells
  2. ' 2. creates a named range
  3. ' 3. creates a formula
  4. ' 4. and stores the Value in the VB variable foo
  5.  
  6. ' Declarations
  7. Dim XL As object
  8. Dim appXL As object
  9.  
  10. Dim ws As object
  11. Dim sheet As object
  12. Dim cell As object
  13.  
  14. ' Code
  15. Set XL = CreateObject("ExcelApplication")
  16. Set appXL = XL.Application
  17. appXL.Workbooks.Add
  18. Set ws = appXL.ActiveSheet
  19. ws.Cells(1,1).Value = "Test"
  20. ws.Cells(2,1).Value = 100
  21. ws.Range("A2:A5").FillDown
  22. tmp = ws.Range("A1:B5").CreateNames(True, False, False, False)
  23. Set cell = ws.Range("A6")
  24. cell.FormulaR1C1 = "=SUM(Test)"
  25. foo = cell.Value
  26.